package com.ruoyi.resume.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration("resumeThreadPoolConfig")
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        return new ThreadPoolExecutor(
                10, // corePoolSize: 核心线程数
                50, // maximumPoolSize: 最大线程数
                60L, // keepAliveTime: 线程空闲时的存活时间
                TimeUnit.SECONDS, // keepAliveTime单位
                new LinkedBlockingQueue<>(100), // workQueue: 工作队列
                Executors.defaultThreadFactory(), // threadFactory: 线程工厂
                new ThreadPoolExecutor.CallerRunsPolicy() // rejectedExecutionHandler: 拒绝策略
        );
    }
}